# Author    :Dun_Hz
# Time      :2024/7/26 11:43
from cal_time import *


@cal_time
def binary_search(li,val):
    left=0
    right=len(li)-1
    while left<=right:
        mid=(left+right)//2
        if li[mid]==val:
            return mid
        elif li[mid]>val:   #说明要查找的值在mid左侧
            right=mid-1
        else:
            left=mid+1
    return None

if __name__=="__main__":
    li=[1,3,4,6,7,8,23,145,334]
    val=145
    print(binary_search(li,val))